<template>
    <div>
        <el-dialog
            title="物业选择"
            :visible.sync="dialogVisible"
            :modal-append-to-body="false"
            width="1600px"
             :close-on-click-modal="false"
        >
            <div class="card-box">
                <span style="font-size: 16px">临近年审日期：</span>
                <el-radio-group v-model="radio">
                    <el-radio-button label="0">不限</el-radio-button>
                    <el-radio-button label="3">近3个月</el-radio-button>
                    <el-radio-button label="6">近6个月</el-radio-button>
                    <el-radio-button label="12">近1年</el-radio-button>
                </el-radio-group>
                <list-page
                    :pager="pager"
                    :data="tableData"
                    :showSelectSearch="false"
                    :showSelectTips="false"
                    :selectionList="selectionList"
                    :totalSearchData="totalSearchData"
                    :searchDataFrom="searchDataFrom"
                    placeholder="请输入物业名称"
                    @searchReset="searchReset"
                    @searchByKey="searchByKey"
                    @selectionChange="selectionChange"
                    @changePageSize="changePageSize"
                    @changeCurrentPage="changeCurrentPage">
                    <template slot="table">
                        <el-table :data="tableData" align="center" @selection-change="selectionChange">
                            <el-table-column type="selection"></el-table-column>
                            <el-table-column label="授权编号" prop="authorizationNumber"></el-table-column>
                            <el-table-column label="使用单位" prop="unitName"></el-table-column>
                            <el-table-column label="物业名称" prop="propertyName"></el-table-column>
                            <el-table-column label="物业地址" prop="propertyAddress"></el-table-column>
                            <el-table-column label="授权日期" prop="authorizationTime"></el-table-column>
                        </el-table>
                    </template>
                </list-page>
            </div>
            <div class="card-box" style="padding-top: 60px;text-align: right">
                <el-button type="primary" size="small"  @click="ok">确定</el-button>
                <el-button type="primary" size="small"  @click="dialogVisible=false">关闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import pager from '@/assets/vue-mixin/pager'
    import {getProperty,getPropertyById} from '../api/annualauditinfo'
    export default {
        name: "edit-property",
        mixins: [pager],
        data(){
            return{
                dialogVisible:false,
                radio:'0',
                selectionList:[],
                searchForm: {},
                // hxf-0730-配置展开过滤筛选组
                totalSearchData: [
                ],
                // hxf-0730-子组件搜索输入的值在此对象中
                searchDataFrom: {},
                tableData:[
                ]
            }
        },
        methods:{
            show(id){
                this.dialogVisible=true
                if(id){
                    this.searchForm.useCardId=id
                    getProperty(Object.assign(this.pager,this.searchForm)).then(res=>{
                        this.setListData(res.data)
                    })
                }
            },
            ok(){
                if(this.selectionList.length!=1){
                    this.$alert("只能选中一条数据")
                }else{
                    getPropertyById(this.selectionList[0].cardPropertyId).then(res=>{
                        let data=res.data.data
                        if(data){
                            this.$alert("该物业已经年审")
                        }else{
                            this.dialogVisible=false
                            this.$emit("ok",this.selectionList[0])
                        }
                    })
                    // console.log(this.selectionList[0])
                }
            },
            searchByKey(val) {
                if(val){
                    this.searchForm.propertyName=val
                }else
                    delete this.searchForm.propertyName
                getProperty(Object.assign(this.pager,this.searchForm)).then(res=>{
                    this.setListData(res.data)
                })
            },
            searchReset(){},
            getListData (){}

        },
        watch:{
            radio(){
                this.searchForm.num=this.radio
                getProperty(Object.assign(this.pager,this.searchForm)).then(res=>{
                    this.setListData(res.data)
                })
            }
        }
    }
</script>

